package com.simpleactors;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author Dmitry
 */
abstract class MultipleActorsWrapper extends Actor {
    protected Actor[] actors;
    protected ReentrantLock lock = new ReentrantLock();
    protected final int size;

    public MultipleActorsWrapper(String name, Actor... actors) {
        super(name);
        int i = 0;
        for (Actor actor : actors) {
            actor.setName(name + i);
            i++;
        }
        this.actors = actors;
        size = actors.length;
    }

    @Override
    public void start() {
        for (Actor actor : actors) {
            actor.start();
        }
    }

    @Override
    public void stop() {
        for (Actor actor : actors) {
            actor.stop();
        }
    }

    @Override
    public void receive(Object value, Actor receiver) {
    }

}
